<template>
  <div>
    <div class="progress-steps">
      <div :style="style" class="line"></div>
      <div class="circle-content">
        <div
          class="circle-item"
          :class="selectIndex >= index ? 'active' : ''"
          v-for="(item, index) of circleList"
          :key="index"
        >
          {{ item.label }}
        </div>
      </div>
    </div>
    <el-button @click="prve" :disabled="selectIndex === 0">prve</el-button>
    <el-button @click="next" :disabled="selectIndex === circleList.length - 1"
      >next</el-button
    >
  </div>
</template>

<script>
export default {
  props: {
    circleConfig: {
      type: Object,
      default: () => ({
        list: [
          {
            label: "1",
          },
          {
            label: "2",
          },
          {
            label: "3",
          },
          {
            label: "4",
          },
          {
            label: "5",
          },
          {
            label: "6",
          },
        ],
      }),
    },
  },
  data() {
    return {
      selectIndex: 0,
    };
  },
  methods: {
    prve() {
      this.selectIndex--;
    },
    next() {
      this.selectIndex++;
    },
  },
  computed: {
    circleList() {
      return this.circleConfig.list;
    },
    style(){
        return {
            width: (100 / (this.circleList.length - 1)) * this.selectIndex + '%',
        }
    }
  },
};
</script>

<style lang="scss" scoped>
.progress-steps {
  width: 100%;
  position: relative;
  &::before {
    content: "";
    background-color: #e0e0e0;
    width: 100%;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    z-index: -1;
  }
  .line {
    position: absolute;
    background-color: #3498db;
    width: 0%;
    height: 4px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    transition: width 0.4s;
  }
  .circle-content {
    display: flex;
    justify-content: space-between;
    .circle-item {
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 50%;
      height: 30px;
      width: 30px;
      background-color: #e0e0e0;
      border: 3px solid #e0e0e0;
      transition: border-color 0.5s;
      z-index: 2;
      &.active {
        border-color: #3498db;
      }
    }
  }
}
</style>